<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:c="http://java.sun.com/jsp/jstl/core"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                template="./../template/WorkspaceTemplate.xhtml">

    <ui:define name="top">

    </ui:define>

    <ui:define name="left">

    </ui:define>

    <ui:define name="right">

    </ui:define>

    <ui:define name="content">
        <style>
            .ui-state-highlight.ui-selected {
                color: blueviolet;
            }
            .ui-commandButton-wizard-selected{
                font-weight: bold;
                color: #000000;
            }
            .ui-commandButton-wizard-unselected{
                font-weight: bold;
                color: #AFAFAF;
            }
        </style>

        <h:form id="purchaseOrderForm" style="font-size: 85%">

            <h2>View Raw Material Purchase Order</h2>
            <br/>

            <p:panel >

                <br/>
                <br/>
                <h:panelGrid id="panelgrid1" columns="6" cellpadding="10" style="width: 100%">
                    <h:outputLabel style="font-weight: bold" value="Supplier ID: "/>
                    <h:outputText id="supplierId" style="font-weight: bold" value="#{prManagerBean.rmpo.supplier.supplierId}"/>
                    <h:outputLabel style="font-weight: bold" value=""/>
                    <h:outputLabel value=""/>
                    <h:outputLabel style="font-weight: bold" value="Purchase Order Number: "/>
                    <h:outputLabel value="#{prManagerBean.rmpo.poNum}"/>

                    <h:outputLabel style="font-weight: bold" value="Supplier Name: "/>
                    <p:inputText id="supplierName" value="#{prManagerBean.rmpo.supplier.supplierName}" disabled="true" required="true" requiredMessage="Supplier needs to be selected"/>
                    <h:outputLabel value=""/>
                    <h:outputLabel style="font-weight: bold" value=""/>
                    <h:outputLabel style="font-weight: bold" value="Purchase Order Date: "/>
                    <h:outputText id="rfqNumber" value="#{prManagerBean.rmpo.poDate}">
                        <f:convertDateTime pattern="MMMM dd, yyyy"/>
                    </h:outputText>

                    <h:outputLabel style="font-weight: bold" value="Currency: "/>
                    <h:outputText value="#{prManagerBean.rmpo.currency?'SGD':'USD'}"/>
                    <h:outputLabel style="font-weight: bold" value=""/>
                    <h:outputLabel style="font-weight: bold" value=""/>
                    <h:outputLabel style="font-weight: bold" value=""/>
                    <h:outputLabel style="font-weight: bold" value=""/>

                </h:panelGrid>

                <br/>
                <br/>
                <br/>
                <h:outputText value="Order Items" style="font-weight: bold; font-size: 110%"/>
                <p:separator/> 
                <br/>
                <h:panelGrid columns="2" cellpadding="10">
                    <h:outputLabel style="font-weight: bold" value="Urgent: "/>
                    <h:outputText value="#{prManagerBean.rmpo.urgent?'Urgent':'Not Urgent'}"/>
                </h:panelGrid>
                <br/>
                <p:dataTable id="items" var="rec" rowIndexVar="row" value="#{prManagerBean.rmpo.itemLines}" emptyMessage="No items added.">
                    <p:column headerText="S/N" >
                        <h:outputText value="#{row + 1}"/>
                    </p:column>
                    <p:column headerText="Raw Material Item">
                        <h:outputText value="#{rec.rawMaterialSupplyInformation.rawMaterial.name}"/>
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            Quantity <br/> (Lot Number)
                        </f:facet>
                        <h:outputText value="#{rec.qty}"/>
                    </p:column>
                    <p:column headerText="Unit Price (SGD)" rendered="#{prManagerBean.rmpo.currency}">
                        <h:outputText value="#{rec.rawMaterialSupplyInformation.unitPriceSGD}">
                            <f:convertNumber type="currency"/>
                        </h:outputText>
                    </p:column>
                    <p:column headerText="Unit Price per Lot (SGD)" rendered="#{prManagerBean.rmpo.currency}">
                        <h:outputText value="#{rec.rawMaterialSupplyInformation.unitLotPriceSGD}">
                            <f:convertNumber type="currency"/>
                        </h:outputText>
                    </p:column>
                    <p:column headerText="Sub-total (SGD)" rendered="#{prManagerBean.rmpo.currency}">
                        <h:outputText value="#{rec.subtotalSGD}">
                            <f:convertNumber type="currency"/>
                        </h:outputText>
                    </p:column>
                    <p:column headerText="Unit Price (USD)" rendered="#{!prManagerBean.rmpo.currency}">
                        <h:outputText value="#{rec.rawMaterialSupplyInformation.unitPriceUSD}">
                            <f:convertNumber type="currency"/>
                        </h:outputText>
                    </p:column>
                    <p:column headerText="Unit Price per Lot (USD)" rendered="#{!prManagerBean.rmpo.currency}">
                        <h:outputText value="#{rec.rawMaterialSupplyInformation.unitLotPriceUSD}">
                            <f:convertNumber type="currency"/>
                        </h:outputText>
                    </p:column>
                    <p:column headerText="Sub-total (USD)" rendered="#{!prManagerBean.rmpo.currency}">
                        <h:outputText value="#{rec.subtotalUSD}">
                            <f:convertNumber type="currency"/>
                        </h:outputText>
                    </p:column>
                </p:dataTable>

                <br/>
                <br/>
                <br/>
                <h:outputText value="Comments" style="font-weight: bold; font-size: 110%"/>
                <p:separator/> 
                <br/>
                <h:panelGrid id="panelgrid4" columns="6" cellpadding="10">
                    <h:outputText value="#{prManagerBean.rmpo.comments}"/>
                </h:panelGrid>
                <br/>

                <br/>
                <br/>
                <p:separator style="height:1px; border-color: #000000; color: #000000; background-color: #000000; outline-color: #000000"/> 
                <div align="right">
                    <h3>
                        <h:panelGrid columns ="2" cellpadding="2" style="text-align: right">
                            <h:outputLabel style="font-weight: bold" value="Sub-total: "/>
                            <h:outputText value="#{prManagerBean.rmpo.subtotalSGD}" rendered="#{prManagerBean.rmpo.currency}">
                                <f:convertNumber type="currency" />
                            </h:outputText>
                            <h:outputText value="#{prManagerBean.rmpo.subtotalUSD}" rendered="#{!prManagerBean.rmpo.currency}">
                                <f:convertNumber type="currency" />
                            </h:outputText>
                            <h:outputLabel style="font-weight: bold" value="Tax: "/>
                            <h:outputText value="#{prManagerBean.rmpo.taxSGD}" rendered="#{prManagerBean.rmpo.currency}">
                                <f:convertNumber type="currency" />
                            </h:outputText>
                            <h:outputText value="#{prManagerBean.rmpo.taxUSD}" rendered="#{!prManagerBean.rmpo.currency}">
                                <f:convertNumber type="currency" />
                            </h:outputText>
                        </h:panelGrid>
                    </h3>
                    <h2>
                        <h:panelGrid columns ="2" cellpadding="10">
                            <h:outputLabel for="total" style="font-weight: bold" value="Total: "/>
                            <h:outputText value="#{prManagerBean.rmpo.totalSGD}" rendered="#{prManagerBean.rmpo.currency}">
                                <f:convertNumber type="currency" />
                            </h:outputText>
                            <h:outputText value="#{prManagerBean.rmpo.totalUSD}" rendered="#{!prManagerBean.rmpo.currency}">
                                <f:convertNumber type="currency" />
                            </h:outputText>
                        </h:panelGrid>
                    </h2>
                </div>
            </p:panel>

            <br/>
            <br/>
            <div align="right">
                <p:commandButton image="ui-icon ui-icon-arrowreturnthick-1-w" value="Back to Purchase Plan" title="Back" actionListener="#{prManagerBean.back}" action="createPurchasePlan?faces-redirect=true"/>
            </div>
            <br/>
            <br/>
            <br/>
        </h:form>

    </ui:define>

    <ui:define name="bottom">

    </ui:define>

</ui:composition>